package com.xbongbong.saas.enums.mini;

import com.xbongbong.paas.constant.PaasConstant;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 应用模块名称<p>
 * 代码描述<p>
 * Company: 逍邦网络科技有限公司<p>
 *
 * @author chenshan
 * @version v1.0
 * @since 2020/10/12 10:38 上午
 */
@Getter
@ToString
public enum PluginTypeEnum {
    //1代表业绩排行  2代表销售喜报 3代表访客计划 4业绩排行详情 5喜报详情
    PERFORMANCE_RANKING_LIST(1,"业绩排行列表页"),
    GOOD_NEWS_LIST(2,"销售喜报列表页"),
    VISITORS_TO_PLAN(3,"访客计划列表页"),
    PERFORMANCE_RANKING_DETAIL(4,"业绩排行详情页"),
    GOOD_NEWS_DETAIL(5,"销售喜报详情页"),
    
    UNKNOWN(404,""),
    ;
    private Integer code;
    private String memo;
    
    PluginTypeEnum(Integer code, String memo) {
        this.code = code;
        this.memo = memo;
    }
    public static PluginTypeEnum getByCode(Integer code) {
        for ( PluginTypeEnum cacheCode : values()) {
            if (cacheCode.getCode().equals(code)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
    
    public static List<PluginTypeEnum> getAllEnum() {
        List<PluginTypeEnum> managePushEnumList = new ArrayList<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for ( PluginTypeEnum cacheCode : values()) {
            if (cacheCode == UNKNOWN) {
                continue;
            }
            managePushEnumList.add(cacheCode);
        }
        return managePushEnumList;
    }
    
    public static Map<Integer,PluginTypeEnum> getAllMap() {
        Map<Integer,PluginTypeEnum> managePushEnumMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for ( PluginTypeEnum cacheCode : values()) {
            if (cacheCode == UNKNOWN) {
                continue;
            }
            managePushEnumMap.put(cacheCode.getCode(),cacheCode);
        }
        return managePushEnumMap;
    }
}
